<?php if($ktd_categories != NULL) : ?>
<?php foreach($ktd_categories as $ktd_category): ?>
    <h1><?php echo $ktd_category->getName() ?></h1>
    <?php foreach($ktd_category->getForums() as $ktd_forum): ?>
        <div class="forumdescbg">
            <h2 style="font-size: 1em"><?php echo link_to($ktd_forum->getName(), 'show_forum', $ktd_forum)?></h2>
             <span class="last_message">
                <?php echo $ktd_forum->getLastMessage() != NULL ? 
                            link_to($ktd_forum->getLastMessage()->getKTDTopic()->getTitle(), 'show_topic', $ktd_forum->getLastMessage()->getKTDTopic())
                                    : '' ?>
             </span>
        </div>
    <?php endforeach; ?>
<?php endforeach ?>
<?php endif ?>